package com.ht.shortlink.project.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ht.shortlink.project.dao.entity.ShortLinkDO;
import com.ht.shortlink.project.dto.req.ShortLinkPageReqDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 *  短链接持久层
 */
public interface ShortLinkMapper extends BaseMapper<ShortLinkDO> {
    @Update("UPDATE t_link SET total_pv = total_pv + #{pv}, total_uv = total_uv + #{uv}, total_uip = total_uip + #{uip} " +
            "WHERE gid=#{gid} AND full_short_url=#{fullShortUrl};")
    void incrTotalStats(@Param("gid") String gid,
                        @Param("fullShortUrl") String fullShortUrl,
                        @Param("pv") Integer pv,
                        @Param("uv") Integer uv,
                        @Param("uip") Integer uip);

    IPage<ShortLinkDO> queryPage(ShortLinkPageReqDTO shortLinkPageReqDTO);
}
